home *** CD-ROM | disk | FTP | other *** search
/ Champak 145 / (Vol 145) Dec 21 2011.iso / Games / kupidon-strike.swf / scripts / __Packages / com / mindjolt / api / as2 / MindJoltSponsoredAPI.as
Encoding:
Text File  |  2011-12-21  |  2.9 KB  |  73 lines

  1. class com.mindjolt.api.as2.MindJoltSponsoredAPI
  2. {
  3.    var session;
  4.    static var flashCookie;
  5.    static var gameId;
  6.    static var key;
  7.    static var connected = false;
  8.    function MindJoltSponsoredAPI()
  9.    {
  10.    }
  11.    static function connect(_gameId, _key)
  12.    {
  13.       trace("aaaa");
  14.       if(!com.mindjolt.api.as2.MindJoltSponsoredAPI.connected)
  15.       {
  16.          _root.MindJoltSponsoredAPI = com.mindjolt.api.as2.MindJoltSponsoredAPI;
  17.          com.mindjolt.api.as2.MindJoltSponsoredAPI.flashCookie = SharedObject.getLocal("com.mindjolt","/");
  18.          com.mindjolt.api.as2.MindJoltSponsoredAPI.gameId = _gameId.toUpperCase();
  19.          com.mindjolt.api.as2.MindJoltSponsoredAPI.key = _key.toUpperCase();
  20.          com.mindjolt.api.as2.MindJoltSponsoredAPI.connected = true;
  21.       }
  22.    }
  23.    static function submitScore(name, score, mode)
  24.    {
  25.       var _loc4_ = null;
  26.       if(com.mindjolt.api.as2.MindJoltSponsoredAPI.flashCookie.data.userToken != null)
  27.       {
  28.          _loc4_ = com.mindjolt.api.as2.MindJoltSponsoredAPI.flashCookie.data.userToken;
  29.       }
  30.       else
  31.       {
  32.          _loc4_ = null;
  33.       }
  34.       var _loc8_ = new com.meychi.ascrypt.RC4();
  35.       var _loc5_ = com.meychi.ascrypt.RC4.encrypt("score=" + score + "&name=" + escape(name) + (mode == null ? "" : "&mode=" + escape(mode)) + (_loc4_ == null ? "" : "&userToken=" + escape(_loc4_)),com.mindjolt.api.as2.MindJoltSponsoredAPI.key);
  36.       var _loc3_ = new LoadVars();
  37.       var _loc6_ = new LoadVars();
  38.       _loc3_.gameId = com.mindjolt.api.as2.MindJoltSponsoredAPI.gameId;
  39.       _loc3_.session = _loc5_;
  40.       _loc6_.onLoad = function(success)
  41.       {
  42.          if(success)
  43.          {
  44.             var _loc4_ = this.session;
  45.             if(_loc4_ != null)
  46.             {
  47.                var _loc5_ = new com.meychi.ascrypt.RC4();
  48.                var _loc2_ = new LoadVars();
  49.                _loc2_.decode(com.meychi.ascrypt.RC4.decrypt(_loc4_,com.mindjolt.api.as2.MindJoltSponsoredAPI.key));
  50.                var _loc3_ = _loc2_.userToken;
  51.                trace("result [" + _loc2_.result + "]");
  52.                if(_loc3_ != null)
  53.                {
  54.                   trace("we are being told to set userToken [" + _loc3_ + "]");
  55.                   com.mindjolt.api.as2.MindJoltSponsoredAPI.flashCookie.data.userToken = _loc3_;
  56.                   com.mindjolt.api.as2.MindJoltSponsoredAPI.flashCookie.flush();
  57.                }
  58.             }
  59.          }
  60.          else
  61.          {
  62.             trace("IOError in SubmitScore");
  63.          }
  64.       };
  65.       _loc3_.sendAndLoad("http://game.mindjolt.com/servlet/GameScore",_loc6_,"POST");
  66.    }
  67.    static function openLink(linkId, mode)
  68.    {
  69.       var _loc1_ = "http://game.mindjolt.com/servlet/GameLink?key=" + com.mindjolt.api.as2.MindJoltSponsoredAPI.gameId + "&link=" + linkId + (mode == null ? "" : "&mode=" + escape(mode)) + "&httpref=" + escape(_url);
  70.       getURL(_loc1_,"_blank");
  71.    }
  72. }
  73.